﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System;
namespace TVersityDotNet.HelperTypes
{
    /// <summary>
    /// Small struct representing the spec version
    /// </summary>
    public struct SpecVersion : IEquatable<SpecVersion>
    {
        /// <summary>
        /// Spec version's Major number
        /// </summary>
        public int Major { get; set; }
        /// <summary>
        /// Spec version's Minor number
        /// </summary>
        public int Minor { get; set; }

        /// <summary>
        /// Used to validate if 2 Specversions are the same
        /// </summary>
        /// <param name="obj">The SpecVersion to compare against</param>
        /// <returns>True if they are equal, false if not</returns>
        public override bool Equals(object obj)
        {            
            var toCompare = (SpecVersion)obj;
            return this.Equals(toCompare);
        }

        /// <summary>
        /// Used to validate if 2 Specversions are the same
        /// </summary>
        /// <param name="other">The SpecVersion to compare against</param>
        /// <returns>True if they are equal, false if not</returns>
        public bool Equals(SpecVersion other)
        {
            return (this.Major.Equals(other.Major) && this.Minor.Equals(other.Minor));
        }

        /// <summary>
        /// Used to validate if 2 Specversions are the same
        /// </summary>
        /// <param name="specVersion1">The first SpecVersion to compare</param>
        /// <param name="specVersion2">The second SpecVersion to compare</param>
        /// <returns>True if they are equal, false if not</returns>
        public static bool operator ==(SpecVersion specVersion1, SpecVersion specVersion2)
        {
            return specVersion1.Equals(specVersion2);
        }

        /// <summary>
        /// Used to validate if 2 Specversions are different
        /// </summary>
        /// <param name="specVersion1">The first SpecVersion to compare</param>
        /// <param name="specVersion2">The second SpecVersion to compare</param>
        /// <returns>False if they are equal, true if not</returns>
        public static bool operator !=(SpecVersion specVersion1, SpecVersion specVersion2)
        {
            return !specVersion1.Equals(specVersion2);
        }

        /// <summary>
        /// Returns this object's HashCode        
        /// </summary>
        /// <returns>The object's HashCode</returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }

    /// <summary>
    /// Class representing a description
    /// </summary>
    public class Description
    {
        public SpecVersion TVSpecVersion { get; set; }
        public Device TVDevice{ get; set; }
        public Collection<TVIcon> TVIcons { get; private set; }
        public Collection<TVService> TVServices{ get; private set; }

        /// <summary>
        /// Constructor for Description
        /// </summary>
        public Description(SpecVersion specVersion, Device device, Collection<TVIcon> listOfIcons, Collection<TVService> listOfServices)
        {
            this.TVSpecVersion = specVersion;
            this.TVDevice = device;
            this.TVServices = listOfServices;
            this.TVIcons = listOfIcons;
        }
    }
}

